<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Flip Sort </title>
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Flip Sort</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p>
Sorting in computer science is an important part. Almost every problem can be solved
effeciently if sorted data are found. There are some excellent sorting algorithm which 
has already acheived the lower bound nlgn. In this problem we will also discuss about
a new sorting approach. In this approach only one operation ( Flip ) is available and that
is you can exchange two adjacent terms. If you think a while, you will see that it is
always possible to sort a set of numbers in this way.
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">The Problem</a></font></h2>
<p>
A set of integers will be given. Now using the above approach we want to sort 
the numbers in ascending order. You have to find out the minimum number of
flips required. Such as to sort "1 2 3" we need no flip operation 
whether to sort "2 3 1" we need at least 2 flip operations.
</p><p>

</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">The Input</a></font></h2>
<p>
The input will start with a positive integer N ( N&lt;=1000 ). In next few lines
there will be N integers.
Input will be terminated by EOF.
</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">The Output</a></font></h2>
<p>
For each data set print "Minimum exchange operations : M" where M is the minimum
flip operations required to perform sorting. Use a seperate line for
each case.
</p><h2><font color="#0070e8"><a name="SECTION0001005000000000000000">Sample Input</a></font></h2>
<p>
</p><pre>3 
1 2 3
3
2 3 1
</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001006000000000000000">Sample Output</a></font></h2>
<p>
</p><pre>Minimum exchange operations : 0
Minimum exchange operations : 2
</pre>

<pre><hr><i>
<h3>Md. Kamruzzaman</h3></i>
</pre>
</body></html>